﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YAPL.Util {
	public static class Require {
		public static void Null(object obj) {
			Null(obj, "Argument should be null");
		}
		public static void Null(object obj, string exceptionMessage) {
			if (obj != null)
				throw new ArgumentException(exceptionMessage);
		}
		public static void NotNull(object obj) {
			NotNull(obj,"Argument shouldn't be null");
		}
		public static  void NotNull(object obj, string exceptionMessage) {
			if (obj == null)
				throw new ArgumentNullException(exceptionMessage);
		}
		public static void HasType(object o, Type t) {
			HasType(o,t,"Agrument type missmatch");
		}
		public static void HasType(object o, Type t, string exceptionMessage) {
			if (o.GetType() != t)
				throw new ArgumentException(exceptionMessage);
		}

		public static void True(bool condition) {
			if (!condition)
				throw new ArgumentException("Bad condition");
		}

		public static void True(bool condition, string exceptionMessage) {
			if (!condition)
				throw new ArgumentException(exceptionMessage);
		}

		public static void NotEmpty(string s) {
			NotEmpty(s, "String shouldn't be empty");
		}

		public static void NotEmpty(string s, string exceptionMessage) {
			if (string.IsNullOrEmpty(s))
				throw new ArgumentException(exceptionMessage);
		}
	}
}
